/**
 * 
 */
package com.scpii.universal.hibernate.dao.impl;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.scpii.universal.hibernate.dao.AttributeListDao;
import com.scpii.universal.hibernate.entity.AttributeListTab;

/**
 * genericWeb
 * @author weny
 * 2012-7-6上午10:46:29
 */
@Repository
public class AttributeListDaoImpl extends BaseDaoImpl<AttributeListTab, Integer> implements AttributeListDao {

	@Override
	public List<AttributeListTab> getAttriListByType(int intAttrListType) {
		List<AttributeListTab> attrList = new ArrayList<AttributeListTab>();
		
		StringBuffer hql = new StringBuffer();
		hql = hql.append("SELECT * FROM AttributeListTab t WHERE t.intAttrType=:intAttriListType AND t.intDeleteSign=0");
		
		Map<String, Object> argsMap = new HashMap<String, Object>();
		argsMap.put("intAttriListType", intAttrListType);
		
		attrList = this.hqlGetList(hql.toString(), argsMap);
		return attrList;
	}

	@Override
	public Integer getMaxId() {
		String sql = "select max(int_attr_list_id) from attribute_list_tab";
		return ((BigDecimal) getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(sql).uniqueResult()).intValue();
	}
}
